<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core">

    <h:form id="frmTitle">
        <p:growl id="msgs" showDetail="false"/>
        <h:panelGrid columns="2" cellpadding="1">
            <h:outputText value="#{msgs.campusTituloLista}" styleClass="fontTitle"/>
        </h:panelGrid>
    </h:form>
        
    <h:panelGrid columns="2" width="100%">
        
        <h:form id="frmSearch">
            
            <h:panelGrid columns="3">
                
                <p:commandLink id="refreshTable" actionListener="#{campusMB.atualizarTabela}" title="#{msgs.btnAtualizar}"  update=":frmDataTable:tbl" >
                    <h:graphicImage value="img/refresh.png" style="border: 0" />
                </p:commandLink>
                    
                <p:inputText id="txtBusca" value="#{campusMB.busca}" size="35" />
                <p:commandButton id="btnSearch" value="#{msgs.btnBuscar}" alt="#{msgs.btnBuscar}" title="#{msgs.btnBuscar}" actionListener="#{campusMB.buscar}" icon="ui-icon ui-icon-search" update=":frmDataTable:tbl"/>
                    
            </h:panelGrid>
                
        </h:form>
            
    </h:panelGrid>

    <h:form id="frmDataTable">

        <p:fieldset legend="#{msgs.campusLgdLista}">

            <h:panelGrid width="100%">            

                <p:dataTable id="tbl" var="tbl" paginator="true" paginatorPosition="bottom" rowsPerPageTemplate="5,10,15" rows="10"
                             emptyMessage="#{msgs.msgTabelaVazia}" value="#{campusMB.lscampus}">
                    <f:facet name="header">
                        <h:outputText value="#{msgs.campusTblTitulo}"/>                    
                    </f:facet>
                    
                    <p:column>
                            <f:facet name="header">
                                <h:outputText value="#{msgs.colNome}"/>
                            </f:facet>
                        <h:outputText value="#{tbl.descricao}"/>
                   </p:column>
                              
                    <p:column>
                            <f:facet name="header">
                                <h:outputText value="#{msgs.colInstituicao}"/>
                            </f:facet>
                        <h:outputText value="#{tbl.instituicao.nome}"/>
                   </p:column>
                    
                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="#{msgs.colTelefone}"/>
                        </f:facet>
                        <h:outputText value="#{tbl.telefone}"/>
                    </p:column>
                    
                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="#{msgs.colDtCriacao}"/>
                        </f:facet>
                        <h:outputText value="#{tbl.dtcriacao}">
                            <f:convertDateTime pattern="dd/MM/yyyy"/>
                        </h:outputText>
                    </p:column>
                
                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="#{msgs.colStatus}"/>
                        </f:facet>
                        <h:outputText value="#{campusMB.strStatusLabel(tbl.status)}"/>
                    </p:column>
                     
                    <p:column style="width:120px">
                        <p:commandButton id="btnVisualizar" alt="#{msgs.btnVisualizar}" title="#{msgs.btnVisualizar}" icon="ui-icon ui-icon-search" oncomplete="dlgVisualizar.show()" actionListener="#{campusMB.visualizar(tbl)}" update=":frmVisualizar" />
                        <p:commandButton id="btnEditar"  alt="#{msgs.btnEditar}" title="#{msgs.btnEditar}" icon="ui-icon ui-icon-pencil" action="#{campusMB.editar}" ajax="false" >
                            <f:param id="idcampus" name="idcampus" value="#{tbl.id}"/>
                        </p:commandButton>
                        <p:commandButton id="btnExcluir" alt="#{msgs.btnExcluir}" title="#{msgs.btnExcluir}" icon="ui-icon ui-icon-close" oncomplete="cfmDlgExcluir.show()" actionListener="#{campusMB.selecionarRegistro(tbl)}" update=":frmExcluir"/>
                    </p:column>
                   
                </p:dataTable>
            
            </h:panelGrid>
        </p:fieldset>
    </h:form>
    
    <h:form id="frmVisualizar">

        <p:dialog header="#{msgs.visualizar}" widgetVar="dlgVisualizar" width="750"  resizable="false" modal="true" styleClass="styleDialog">

            <p:fieldset legend="#{msgs.campusDlgLgdVisualizar}">

                <h:panelGrid columns="2">
                    
                    <h:outputLabel value="#{msgs.campusLblInstituicao}: "/>
                    <h:outputText value="#{campusMB.strinstituicao}"/>
                        
                    <h:outputLabel value="#{msgs.campusLblNome}: "/>
                    <h:outputText value="#{campusMB.strdescricao}"/>
                        
                    <h:outputLabel value="#{msgs.campusLblTelefone}: "/>
                    <h:outputText value="#{campusMB.strtelefone}"/>
                        
                    <h:outputLabel value="#{msgs.campusLblPais}: "/>
                    <h:outputText value="#{campusMB.strpais}"/>
                    
                    <h:outputLabel value="#{msgs.campusLblEstado}: "/>
                    <h:outputText value="#{campusMB.strestado}"/>
                    
                    <h:outputLabel value="#{msgs.campusLblCidade}: "/>
                    <h:outputText value="#{campusMB.strcidade}"/>
                    
                    <h:outputLabel value="#{msgs.campusLblRua}: "/>
                    <h:outputText value="#{campusMB.strrua}"/>                   
                    
                    <h:outputLabel value="#{msgs.campusLblNumero}: "/>
                    <h:outputText value="#{campusMB.strnumero}"/>                    
                    
                    <h:outputLabel value="#{msgs.campusLblCep}: "/>
                    <h:outputText value="#{campusMB.strcep}"/>
                    
                    <h:outputLabel value="#{msgs.campusLblTelefone}: "/>
                    <h:outputText value="#{campusMB.strtelefone}"/>
                        
                        
                    <h:outputLabel value="#{msgs.campusLblDtCriacao}: "/>
                    <h:outputText value="#{campusMB.strdtcriacao}">
                        <f:convertDateTime pattern="dd/MM/yyyy"/>
                    </h:outputText>
                        
                    <h:outputLabel value="#{msgs.campusLblStatus}: "/>
                    <h:outputText value="#{campusMB.strstatus}"/>                

                 </h:panelGrid>

            </p:fieldset>

            <p:commandButton style="width:90px;margin-bottom: 10px;margin-top: 10px;" value="#{msgs.btnFechar}" alt="#{msgs.btnFechar}" title="#{msgs.btnFechar}" onclick="dlgVisualizar.hide()" styleClass="centerButton"/>

        </p:dialog>

    </h:form>
    
    <h:form id="frmExcluir">

        <p:confirmDialog id="confirmDialogExcluir" header="#{msgs.campusDlgTituloExcluir}" message=" #{msgs.dlgMsgExcluir} #{campusMB.campusselecionado.descricao} ?"
                         width="300" height="60" severity="alert" widgetVar="cfmDlgExcluir">

            <p:commandButton value="#{msgs.btnSim}" oncomplete="cfmDlgExcluir.hide()" alt="#{msgs.btnSim}" title="#{msgs.btnSim}" actionListener="#{campusMB.excluir}"
                             update=":frmTitle:msgs,:frmDataTable:tbl"/>
            <p:commandButton value="#{msgs.btnNao}" onclick="cfmDlgExcluir.hide()" alt="#{msgs.btnNao}" title="#{msgs.btnNao}" type="button"/>

        </p:confirmDialog>

    </h:form>
</html>

